//
// @Auther: by wujehy 
// @Email:wujehy@qq.com
// @Data:20-4-14
// @Time:下午2:36
//

#ifndef TESTSERVER_USERDATABASEFACTORY_H
#define TESTSERVER_USERDATABASEFACTORY_H

#include "SQLiteCpp/Database.h"

class UserDataBaseFactory
{
private:
    // 数据库 对象,sqliteWrapper 传入
    SQLite::Database *m_Db = nullptr;
public:
    UserDataBaseFactory(SQLite::Database *mDb);

    int initUserTable();

    /**
     * @brief 添加一个用户
     * @param username
     * @param passwordSrc
     * @param email
     * @return
     */
    int insertUser(std::string &username, std::string &passwordMd5, std::string &email);

    /**
     * @brief 判断用户是否可以
     * @param username
     * @param passwordmd5
     * @param email
     * @return
     */
    int checktUser(std::string &username, std::string &passwordmd5, std::string email = "");

    /**
     * @brief 判断用户是否存在
     * @param username
     * @return
     */
    int existUser(std::string &username);

    int addUser(std::string &username, std::string &passwordMd5, std::string &email);

    int updataPassword(std::string &username, std::string &oldpasswordMd5, std::string &newPasswordMd5);

    int changePassword(std::string &username, std::string &newPassword);

    int64_t getUidByUsername(std::string &username);
};


#endif //TESTSERVER_USERDATABASEFACTORY_H
